Congestion control method and network device

ABSTRACT

This application provides a congestion control method and a network device. The method includes: receiving a first message sent by a second network device, where the first message carries an active flow quantity, and the active flow quantity is a quantity determined by the second network device based on a data flow to which data packets received from a first network device belong; determining, based on the active flow quantity and rated receiving bandwidth of the second network device, packet sending control information used to send the data flow to the second network device; and sending the data flow to the second network device based on the packet sending control information. This application can better control congestion, thereby reducing network packet loss.

CROSS-REFERENCE TO RELATED APPLICATIONS

This application is a continuation of International Application No.PCT/CN2019/094171, filed on Jul. 1, 2019, which claims priority toChinese Patent Application No. 201811119579.8, filed on Sep. 25, 2018.The disclosures of the aforementioned applications are herebyincorporated by reference in their entireties.

TECHNICAL FIELD

This application relates to the field of network technologies, and morespecifically, to a network device and a method for congestion control.

BACKGROUND

With the rise of new technological advancements such as artificialintelligence, enterprise storage, and the like, a demand of a datacenter network for a low delay characteristic is becoming increasinglyurgent. It is very important to control congestion of the data centernetwork so as to ensure the low delay characteristic of the data centernetwork.

In a conventional congestion control method, a receive end feeds backcongestion information of a network to a transmit end, and the transmitend adjusts a data sending rate based on the congestion informationafter learning the congestion information of the network. For example,when the network is congested, the transmit end decreases a sending rateof data packets; and when the network is not congested, the transmit endgradually increases the sending rate of the data packets.

In the foregoing solution, the transmit end gradually adjusts thesending rate of the data packets after learning the congestion state ofthe network. The change of the rate is relatively slow, and a certaindelay may be generated in the transmission process of the data packets,and consequently, congestion control efficiency is not high.

SUMMARY

This application provides a network device and method performed by thenetwork device for controlling network congestion, so as to reducenetwork packet loss.

According to a first aspect, a congestion control method is provided,wherein a network device performs the method to reduce congestion in adata center network, the data center network includes a first networkdevice and a second network device, and the first network device isconfigured to send a data flow to the second network device. The methodincludes: The first network device receives a first message sent by thesecond network device, where the first message carries an active flowquantity, and the active flow quantity is a quantity determined by thesecond network device based on a data flow to which data packetsreceived from the first network device belong; the first network devicedetermines, based on the active flow quantity and rated receivingbandwidth of the second network device, packet sending controlinformation used to send the data flow to the second network device,where the packet sending control information indicates that actualreceiving bandwidth of the second network device reaches the ratedreceiving bandwidth when the first network device sends the data flow tothe second network device based on the packet sending controlinformation; and the first network device sends the data flow to thesecond network device based on the packet sending control information.

The active flow quantity may refer to a quantity of data flows in whichdata packets are being transmitted within a certain statistical period.Specifically, the active flow quantity may be a quantity of data flowsthat is determined by the second network device based on a data flow towhich data packets received from the first network device within astatistical period belong.

Optionally, the data flow sent by the first network device to the secondnetwork device based on the packet sending control information isencapsulated into remote direct memory access over converged Ethernetversion 2 (remote direct memory access over converged ethernet version2, RoCEv2) packets.

Optionally, the first message is carried in an option field in anacknowledgement (Acknowledgement, ACK) packet.

It should be understood that the data flow sent by the first networkdevice to the second network device based on the packet sending controlinformation may be one data flow (in this case, the data flow may be anyone of all data flows sent by the first network device to the secondnetwork device), or may be a plurality of data flows (the plurality ofdata flows may be all data flows sent by the first network device to thesecond network device).

The packet sending control information is used to control the firstnetwork device to send the data flow to the second network device; andwhen the first network device sends the data flow to the second networkdevice based on the packet sending control information, the actualbandwidth of the second network device can reach the rated receivingbandwidth of the second network device.

The rated receiving bandwidth of the second network device may be fixedbandwidth. When the first network device is configured, information suchas the rated receiving bandwidth of the second network device may bedirectly configured for the first network device, so that the firstnetwork device can obtain the rated receiving bandwidth of the secondnetwork device from the configuration information.

In this application, the packet sending control information isdetermined based on the active flow quantity and the rated receivingbandwidth of the second network device, and the data flow sent from thefirst network device to the second network device is controlled based onthe packet sending control information, so that congestion control canbe better performed, thereby reducing network packet loss.

With reference to the first aspect, in some implementations of the firstaspect, that the first network device determines, based on the activeflow quantity and rated receiving bandwidth of the second networkdevice, packet sending control information used to send the data flow tothe second network device includes: When the active flow quantity isless than a first threshold, the first network device determines, basedon the following formula, the packet sending control information used tosend the data flow to the second network device:

$V = \frac{C*T}{active\_ qp}$

where C is the rated receiving bandwidth of the second network device,active_qp is the active flow quantity, T is a time required for a datapacket sent by the first network device to the second network device toarrive at the second network device when the network is idle, and V is adata volume of the data flow sent by the first network device to thesecond network device within T. That the first network device sends thedata flow to the second network device based on the packet sendingcontrol information includes: The first network device sends datapackets with a data volume V in the data flow to the second networkdevice within T.

The data volume (data volume) may be a length of the data packets in thedata flow. For example, a data flow 1 includes a data packet 1, a datapacket 2, and a data packet 3, where each data packet has a length of 4bytes, and then the data flow 1 has a length of 12 bytes.

There are many methods for obtaining T. These methods are describedbelow as examples.

For example, when the network is idle, a sending time and an arrivaltime of a data packet sent by the first network device to the secondnetwork device may be recorded, and then T may be obtained bysubtracting the sending time from the arrival time.

In addition, when the network is idle, the first network device mayalternatively continuously send a plurality of data packets (forexample, 1000 data packets) to the second network device, and then atime required for each data packet sent from the first network device tothe second network device may be obtained based on the recorded time,and all times may be averaged to obtain an average time; and finally theaverage time is determined as T.

The first threshold may be set based on experience. For example, in ascenario in which there is a relatively large data volume, a relativelylarge value may be set as the first threshold; and in a scenario inwhich there is a relatively small data volume, a relatively small valuemay be set as the first threshold.

The first threshold may alternatively be determined based on the ratedreceiving bandwidth of the second network device, T, and a length of asingle data packet.

Specifically, a value obtained based on C*T/1pkt may be determined asthe first threshold, where 1pkt is the length of a single data packet. Aspecific length of 1pkt may be set based on an actual situation. Indifferent scenarios, 1pkt may be set to different lengths. For example,in some scenarios in which a data transmission volume is relativelysmall (for example, a smart meter periodically reports electricityconsumption information), a relatively small length may be set for 1pkt;and in scenarios in which a data transmission volume s relatively large,a relatively large length may be set for 1pkt. In addition, 1pkt may bedirectly set as a maximum transmission unit (maximum transmission unit,MTU) allowed by the network.

With reference to the first aspect, in some implementations of the firstaspect, that the first network device determines, based on the activeflow quantity and rated receiving bandwidth of the second networkdevice, packet sending control information used to send the data flow tothe second network device includes: When the active flow quantity isgreater than or equal to the first threshold, the first network devicedetermines, based on the following formula, the packet sending controlinformation used to send the data flow to the second network device:

${interval} = \frac{1{pkt}*{active\_ qp}}{C}$

where 1pkt is a length of a single data packet, active_qp is the activeflow quantity, C is the rated receiving bandwidth of the second networkdevice, and “interval” is a time interval between adjacent data packetswhen the first network device sends the data flow. That the firstnetwork device sends the data flow to the second network device based onthe packet sending control information includes: The first networkdevice sends a data packet in the data flow to the second network devicebased on the time interval indicated by “interval”.

The length of the single data packet may be specifically a size of thedata volume of the single data packet, for example, if the size of thedata volume of the single data packet is 3 bytes, the length of thesingle data packet is also 3 bytes.

With reference to the first aspect, in some implementations of the firstaspect, that the first network device determines, based on the activeflow quantity and rated receiving bandwidth of the second networkdevice, packet sending control information used to send the data flow tothe second network device includes: The first network device determines,based on the active flow quantity, the rated receiving bandwidth of thesecond network device, and attribute information of the data flow, thepacket sending control information used to send the data flow to thesecond network device, where the attribute information of the data flowincludes at least one of application information of the data flow ordata volume information of the data flow, the application information ofthe data flow is used to indicate a service type to which a data packetof the data flow belongs, and the data volume information of the dataflow is used to indicate a data volume of data packets that belong tothe data flow and that are sent by the first network device within apreset time.

In this application, when the packet sending control information of thedata flow is determined, the packet sending control information can beproperly determined for the data flow based on the attribute informationof the data flow.

With reference to the first aspect, in some implementations of the firstaspect, that the first network device determines, based on the activeflow quantity, the rated receiving bandwidth of the second networkdevice, and attribute information of the data flow, the packet sendingcontrol information used to send the data flow to the second networkdevice includes: When the active flow quantity is less than a firstthreshold, the first network device determines, based on the followingformula, the packet sending control information used to send the dataflow to the second network device:

$V = \frac{C*T*w}{active\_ qp}$

where C is the rated receiving bandwidth of the second network device,active_qp is the active flow quantity, T is a time required for a datapacket sent by the first network device to the second network device toarrive at the second network device when the network is idle, w is aweight of the data flow, w is determined based on the attributeinformation of the data flow, and V is a data volume of the data flowsent by the first network device to the second network device within T.That the first network device sends the data flow to the second networkdevice based on the packet sending control information includes: Thefirst network device sends data packets with a data volume V in the dataflow to the second network device within T.

In this application, when the data transmission volume of the data flowis determined, the data transmission volume can be properly determinedfor the data flow based on the attribute information of the data flow.

With reference to the first aspect, in some implementations of the firstaspect, that the first network device determines, based on the activeflow quantity, the rated receiving bandwidth of the second networkdevice, and attribute information of the data flow, the packet sendingcontrol information used to send the data flow to the second networkdevice includes: When the active flow quantity is greater than or equalto the first threshold, the first network device determines, based onthe following formula, the packet sending control information used tosend the data flow to the second network device:

${interval} = \frac{1{pkt}*{active\_ qp}*w}{C}$

where 1pkt is a length of a single data packet, active_qp is the activeflow quantity, w is a weight of the data flow, w is determined based onthe attribute information of the data flow, C is the rated receivingbandwidth of the second network device, and “interval” is a timeinterval between adjacent data packets when the first network devicesends the data flow. That the first network device sends the data flowto the second network device based on the packet sending controlinformation includes: The first network device sends the data packet inthe data flow to the second network device based on the time intervalindicated by “interval”.

In this application, when the data packet transmission time interval ofthe data flow is determined, the data packet transmission time intervalcan be properly determined for the data flow based on the attributeinformation of the data flow.

According to a second aspect, a congestion control method is provided,where the method is performed by a network device to reduce congestionin a data center network, the data center network includes a firstnetwork device and a second network device, and the second networkdevice is configured to receive a data flow sent by the first networkdevice. The method includes: The second network device determines anactive flow quantity based on a data flow to which data packets receivedfrom the first network device belong; the second network device sends afirst message to the first network device, where the first messagecarries the active flow quantity, the active flow quantity is used bythe first network device to determine packet sending control informationused to send the data flow to the second network device, and the packetsending control information indicates that actual receiving bandwidth ofthe second network device reaches rated receiving bandwidth of thesecond network device when the first network device sends the data flowto the second network device based on the packet sending controlinformation; and the second network device receives, based on the ratedreceiving bandwidth, the data flow sent by the first network device.

In this application, the second network device reports the active flowquantity to the first network device, so that the first network devicecan determine the packet sending control information based on the activeflow quantity and the rated receiving bandwidth of the second networkdevice, and controls, based on the packet sending control information,the first network device to send the data flow to the second networkdevice, so that the second network device can receive, based on therated receiving bandwidth, the data flow sent by the first networkdevice, and the second network device can reach a full throughput state,thereby improving transmission efficiency of the data flow.

With reference to the second aspect, in some implementations of thesecond aspect, that the second network device determines an active flowquantity based on a data flow to which data packets received from thefirst network device belong includes: The second network device receivesthe initial packet in a first group of data packets sent by the firstnetwork device, and increases a current active flow quantity by 1 toobtain a first active flow quantity; the second network device receivesthe tail packet in the first group of data packets sent by the firstnetwork device, and determines a first congestion value based on aquantity of data packets carrying an external congestion notificationECN identifier in the first group of data packets; when the firstcongestion value is less than a congestion threshold, the second networkdevice decreases the first active flow quantity by 1 to obtain a secondactive flow quantity; and when the first congestion value is greaterthan or equal to the congestion threshold, the second network devicekeeps the first active flow quantity unchanged.

Optionally, the first congestion value is used to indicate a congestiondegree of the first network device when the second network devicereceives the data packet sent by the first network device.

It should be understood that a greater first congestion value indicatesa higher congestion degree of the first network device.

The congestion threshold may be a preset threshold, and the congestionthreshold may be a threshold estimated based on a network status. In ascenario in which broadband utilization is low, a relatively smallcongestion threshold may be set, while in a scenario in which broadbandutilization is high, a relatively large congestion threshold may be set.

For example, in a scenario in which broadband utilization is low, thecongestion threshold may be specifically 0.3, 0.4, 0.5, or the like,while in a scenario in which broadband utilization is high, thecongestion threshold may be specifically 0.6, 0.7, 0.8, or the like.

It should be understood that when the initial packet in the first groupof data packets is received, the current active flow quantity needs tobe increased by 1 to obtain the first active flow quantity. The currentactive flow quantity herein is a quantity of active flows counted by thesecond network device before receiving the initial packet in the firstgroup of data packets. When receiving the initial packet in the firstgroup of data packets, the second network device needs to update theactive flow quantity, that is, to increase the active flow quantitycounted before receiving the initial packet in the first group of datapackets by 1.

After receiving the tail packet in the first group of data packets, thesecond network device needs to update the first active flow quantityagain based on the quantity of the data packets carrying the ECNidentifier in the first group of data packets. If the first congestionvalue is less than the congestion threshold, the active flow quantitycounted by the second network device after receiving the tail packet inthe first group of data packets is the second active flow quantity; andif the first congestion value is greater than or equal to the congestionthreshold, the active flow quantity counted by the first network deviceafter receiving the tail packet in the first group of data packets isthe first active flow quantity. That is, after the tail packet in thefirst group of data packets is received, the counted active flowquantity is the first active flow quantity (when the first congestionvalue is greater than or equal to the congestion threshold) or thesecond active flow quantity (when the first congestion value is lessthan the congestion threshold).

The ECN identifier may be a congestion identifier added by anothernetwork device (which may be specifically switching equipment betweenthe first network device and the second network device) when receivingthe data packet.

Optionally, each data packet may also carry an identifier in a field,and a value of the field is used to indicate a type of the data packet(specifically, the initial packet, the tail packet, or a data packetbetween the initial packet and the tail packet).

Each data packet may also be considered as a packet, and an identifierof each data packet may be carried in a field of the packet. Forexample, when the data packet is a remote direct memory access overconverged Ethernet version 2 (remote direct memory access over convergedethernet version 2, RoCEv2) packet, an identifier of the data packet maybe carried in an opcode field in the RoCEv2 packet, or an identifier ofthe data packet may be carried in a reserved field (such as an rsvd7field) in the RoCEv2 packet.

In this application, when the tail packet in a group of data packets isreceived, a congestion status may be determined based on a quantity ofdata packets carrying the ECN identifier in the group of data packets,and the active flow quantity may be corrected based on the congestionstatus, so that the active flow quantity can be more accurately counted,and a more accurate active flow quantity can be obtained.

Specifically, a conventional solution does not consider the networkcongestion status during counting of the active flow quantity. Actually,the conventional solution counts the active flow quantity based on anideal situation that the network is not congested. When the network iscongested, a quantity of data packets received by a receive end within aperiod is affected, so that the counted active flow quantity isinaccurate. In this application, data packets carrying the ECNidentifier in each group of data packets are counted, so as to estimatenetwork congestion. When the network congestion degree is relativelylow, the active flow quantity can be decreased by 1; and when thenetwork congestion degree is relatively high, the active flow quantitycan be kept unchanged, so that impact of network congestion on theactive flow quantity can be reduced, and the counted active flowquantity is more accurate.

With reference to the second aspect, in some implementations of thesecond aspect, determining a first congestion value based on a quantityof data packets carrying an ECN identifier in the first group of datapackets includes: determining a ratio of the quantity of data packetscarrying the ECN identifier in the first group of data packets to aquantity of data packets in the first group of data packets as the firstcongestion value.

Optionally, the determining a ratio of the quantity of data packetscarrying the ECN identifier in the first group of data packets to aquantity of data packets in the first group of data packets includes:determining a ratio of a total quantity of data packets carrying the ECNidentifier in the first group of data packets to a total quantity ofdata packets in the first group of data packets as the first congestionvalue.

For example, the first group of data packets includes a total of 10 datapackets (including the initial packet and the tail packet), where atotal of five data packets carry the ECN identifier, and then it may bedetermined, through calculation, that the first congestion value is 0.5.

In addition, the ratio of the total quantity of data packets carryingthe ECN identifier in the first group of data packets to the totalquantity of data packets in the first group of data packets mayalternatively be obtained first, and then a product of the ratio and acorrection coefficient is used as the first congestion value. Thecorrection coefficient may be a coefficient set based on an operationstatus of the network.

In this application, the first congestion value is determined based onthe data packets carrying the ECN identifier in the first group of datapackets, so that a current congestion status can be reflected in realtime, and the active flow quantity can be counted more accurately basedon the current congestion status.

With reference to the second aspect, in some implementations of thesecond aspect, after the second network device receives the tail packetin the first group of data packets sent by the first network device, themethod further includes: The second network device receives the initialpacket in a second group of data packets sent by the first networkdevice, and increases a third active flow quantity by 1 to obtain afourth active flow quantity, where the second group of data packets andthe first group of data packets belong to a same data flow, the thirdactive flow quantity is equal to the second active flow quantity whenthe first congestion value is less than the congestion threshold, andthe third active flow quantity is equal to the first active flowquantity when the first congestion value is greater than or equal to thecongestion threshold; the second network device receives the tail packetin the second group of data packets sent by the first network device,and determines a second congestion value of the network based on aquantity of data packets carrying the ECN identifier in the second groupof data packets and the first congestion value; when the secondcongestion value is less than the congestion threshold, the secondnetwork device decreases the fourth active flow quantity by 1 to obtaina fifth active flow quantity; and when the second congestion value isgreater than or equal to the congestion threshold, the second networkdevice keeps the fourth active flow quantity unchanged.

Optionally, the determining a ratio of the quantity of data packetscarrying the ECN identifier in the first group of data packets to aquantity of data packets in the first group of data packets includes:determining a ratio of a total quantity of data packets carrying the ECNidentifier in the first group of data packets to a total quantity ofdata packets in the first group of data packets as the first congestionvalue.

It should be understood that the initial packet, the tail packet, andthe data packet between the initial packet and the tail packet in thefirst group of data packets may all carry the ECN identifier. When eachdata packet in the first group of data packets carries the ECNidentifier, it indicates that network congestion is serious. When asmall quantity of data packets in the first group of data packets carrythe ECN identifier, it indicates that the network congestion degree islow (or the network is relatively smooth).

After the initial packet in the second group of data packets isreceived, the initial packet in the second group of data packets may beprocessed in a manner similar to that of the initial packet in the firstgroup of data packets; and after the tail packet in the second group ofdata packets is received, the second congestion value is determinedbased on both the quantity of data packets carrying the ECN identifierin the second group of data packets and the first congestion value, sothat the second congestion value does not change too much, a slowlychanging congestion value is obtained, and the counted active flowquantity does not change abruptly.

Optionally, after the second network device receives the tail packet inthe second group of data packets sent by the first network device, thesecond congestion value may alternatively be determined based on boththe quantity of data packets carrying the ECN identifier in the firstgroup of data packets and the quantity of data packets carrying the ECNidentifier in the second group of data packets.

Optionally, a ratio of a total quantity of data packets carrying the ECNidentifier in both the first group of data packets and the second groupof data packets to a total quantity of data packets included in both thefirst group of data packets and the second group of data packets isdetermined as the second congestion value.

With reference to the second aspect, in some implementations of thesecond aspect, determining a second congestion value of the networkbased on a quantity of data packets carrying the ECN identifier in thesecond group of data packets and the first congestion value includes:determining a third congestion value of the network based on thequantity of data packets carrying the ECN identifier in the second groupof data packets; and determining the second congestion value based on aformula con2=x1*con3+x2*con1, where con3 is the third congestion value,con1 is the first congestion value, con2 is the second congestion value,x1 is a preset first weight, and x2 is a preset second weight.

It should be understood that in the method according to the secondaspect, the active flow quantity may be counted by a network device at areceive end or switching equipment between a transmit end and thereceive end; when the active flow quantity is counted by the switchingequipment between the transmit end and the receive end, the switchingequipment may feed back the counted active flow quantity to the receiveend for forwarding it to the transmit end.

According to a third aspect, a network device is provided, where thenetwork device includes modules configured to perform the methodsaccording to various implementations of the first aspect or variousimplementations of the second aspect.

According to a fourth aspect, a network device is provided, where thenetwork device includes a memory and a processor, where the memory isconfigured to store a program, and the processor is configured toexecute the program stored in the memory, and when the program stored inthe memory is executed by the processor, the processor is configured toperform the methods according to various implementations of the firstaspect or various implementations of the second aspect.

Optionally, the network device further includes a transceiver; and whenthe program stored in the memory is executed by the processor, theprocessor and the transceiver are configured to perform the methodsaccording to various implementations of the first aspect or variousimplementations of the second aspect.

According to a fifth aspect, a computer-readable storage medium isprovided, where the computer-readable storage medium stores aninstruction, and when the instruction is run on a computer, the computeris enabled to perform the methods according to various implementationsof the first aspect or various implementations of the second aspect.

According to a sixth aspect, a computer program product including aninstruction is provided, where when the computer program product runs ona computer, the computer is enabled to perform the methods according tovarious implementations of the first aspect or various implementationsof the second aspect.

The foregoing computer may be specifically a network device in a datacenter, for example, a server or a transmission device.

BRIEF DESCRIPTION OF DRAWINGS

FIG. 1 is a schematic diagram of a possible application scenarioaccording to an embodiment of this application;

FIG. 2 is a schematic flowchart of a congestion control method accordingto an embodiment of this application;

FIG. 3 is a schematic flowchart of a congestion control method accordingto an embodiment of this application;

FIG. 4 is a schematic flowchart of a congestion control method accordingto an embodiment of this application;

FIG. 5 is a schematic flowchart of a congestion control method accordingto an embodiment of this application;

FIG. 6 is a schematic block diagram of a network device according to anembodiment of this application;

FIG. 7 is a schematic block diagram of a network device according to anembodiment of this application; and

FIG. 8 is a schematic block diagram of a network device according to anembodiment of this application.

DESCRIPTION OF EMBODIMENTS

FIG. 1 is a schematic diagram of a possible application scenario ofembodiments of this application.

As shown in FIG. 1, a transmit end 1, a transmit end 2, and a transmitend 3 may send data flows to a receive end 1 and a receive end 2 througha switch 1 and a switch 2. Both the receive end 1 and the receive end 2may receive, through the switch 1 and the switch 2, the data flows sentfrom the transmit end 1, the transmit end 2, and the transmit end 3 (theswitch 1 and the switch 2 forward the data flows sent from the transmitend 1, the transmit end 2, and the transmit end 3 to the receive end 1and the receive end 2). FIG. 1 is merely a schematic diagram of apossible application scenario of the embodiments of this application.The embodiments of this application may also be implemented in anotherscenario similar to the scenario shown in FIG. 1.

Using the transmit end 1 and the receive end 1 as an example, a dataflow sent by the transmit end 1 to the receive end 1 may lead tocongestion between the transmit end 1 and the receive end 1, andconsequently, a delay of a data packet received by the receive end 1becomes high, and network performance is affected. To perform congestioncontrol, in a conventional solution, the receive end 1 feeds back acongestion status of the data flow to the transmit end 1. When the dataflow leads to congestion, the transmit end 1 gradually reduces a sendingrate of the data flow, and when the data flow does not lead tocongestion, the transmit end can gradually increase the sending rate ofthe data packet. In the conventional solution, the transmit endgradually adjusts the sending rate of the data packet after learning thecongestion status of the network, and therefore the rate changesrelatively slow. This is a passive adjustment after the congestionstatus of the network is known, and the congestion control effect is notvery good.

Therefore, this application provides a new congestion control method,where a sending rate of a data flow is actively adjusted based on anactive flow quantity and rated receiving bandwidth of a receive end, sothat actual receiving bandwidth of the receive end can reach the ratedreceiving bandwidth, and the receive end can reach a full throughputstate, thereby improving transmission efficiency of the data flow.

FIG. 2 is a schematic flowchart of a congestion control method accordingto an embodiment of this application. The method shown in FIG. 2 may beperformed by a network device to reduce congestion in networks such as adata center network and a metropolitan area network. A first networkdevice and a second network device are devices in these networks. Themethod shown in FIG. 2 includes step 101 to step 103. These steps aredescribed in detail below.

101. The second network device sends a first message to the firstnetwork device, and the first network device receives the first message.

The first message carries an active flow quantity, where the active flowquantity is determined by the second network device based on a data flowto which data packets received from the first network device belong.

It should be understood that the term “active flow” may be a definitionof the second network device for a data flow. For the second networkdevice, an active flow may be a data flow in which data packets aretransmitted relatively frequently, and an inactive flow may beconsidered as a data flow in which data packets are transmitted at alonger time interval (for example, a data flow transmits one data packetfor a long time, and such a data flow may be considered as an inactiveflow). Therefore, for the second network device, data flows received bythe second network device may fall into two types: active flows andinactive flows.

In addition, the active flow quantity may refer to a quantity of dataflows in which data packets are being transmitted within a certainstatistical period. Specifically, the active flow quantity may be aquantity of data flows that is determined by the second network devicebased on a data flow to which data packets received from the firstnetwork device within a statistical period belong.

Optionally, before step 101, the first network device sends a data flowto the second network device, and the second network device receives thedata flow sent by the first network device.

When sending a data flow to the second network device, the first networkdevice may send data packets to the second network device in groups.Each group of data packets includes the initial packet and the tailpacket, and a data packet between the initial packet and the tail packethave different identifiers. The second network device may identify theinitial packet and the tail packet in a group of data packets based onthese identifiers, and then count the active flow quantity based on theinitial packet and the tail packet of each group of data packetsreceived, so as to obtain the active flow quantity (details aboutcounting the active flow quantity are described in the method shown inFIG. 3).

It should be understood that before the first network device controls asending rate of the data flow by using the congestion control methodshown in FIG. 1, the data flow may be sent to the second network deviceat an initial rate. The initial rate may be defined by using thefollowing two methods:

Method 1: The first network device determines the rated receivingbandwidth of the second network device as the initial rate, and sendsthe data flow to the second network device based on the rated receivingbandwidth within T.

T is a period from a time when a request packet is sent from the firstnetwork device (the request packet is used to request the second networkdevice to receive a data flow sent by the first network device) to atime when the first network device receives a response packet that isspecific to the request packet and that is sent by the second networkdevice.

Method 2: The initial rate is an initial sending rate per flow that isdefined based on remote direct memory access over converged Ethernetversion 2 (remote direct memory access over converged ethernet version2, RoCEv2).

Specifically, in a possible implementation, the initial rate may be amaximum sending rate allowed by a line card or a sending fabric card ofthe first network device.

In addition, there are two methods for defining the initial packet andthe tail packet in each group of data packets. The first method is todefine the initial packet and the tail packet based on the RoCEv2protocol. Specifically, the data packets may be grouped based on amessage (Message) (the message is a logical group at an applicationlayer): The first packet of the message is considered as the initialpacket, the last packet of the message is considered as the tail packet,and the initial packet and the tail packet may be specifically definedin an opcode field of a base transport header (Base Transport Header,BTH) of a remote direct memory access over converged Ethernet (remotedirect memory access over converged ethernet, RoCE) packet.

In addition to defining the initial packet and the tail packet in thedata packets based on the logical group at the application layer, theinitial packet and the tail packet of the data packet can also bedefined directly based on a segment (segment). Specifically, datapackets within a period that are fed back based on the initial rate orthe active flow quantity can be grouped into a group, the first packetin the segment is referred to as the initial packet, and the last packetin the segment is referred to as the tail packet. The two fields may bedefined in reserved fields (such as an rsvd7 field) in the BTH, and aflag of each field may occupy 1 bit.

Optionally, the first message may directly carry a specific active flowquantity, so that the first network device can directly obtain theactive flow quantity based on the first message.

102. The first network device determines, based on the active flowquantity and the rated receiving bandwidth of the second network device,packet sending control information used to send a data flow to thesecond network device.

The packet sending control information indicates that when the firstnetwork device sends a data flow to the second network device based onthe packet sending control information, the actual receiving bandwidthof the second network device reaches the rated receiving bandwidth. Thatis, the packet sending control information is used to control the firstnetwork device to send a data flow to the second network device; andwhen the first network device sends a data flow to the second networkdevice based on the packet sending control information, the actualbandwidth of the second network device can reach the rated receivingbandwidth of the second network device.

The rated receiving bandwidth of the second network device may be fixedbandwidth. When the first network device is configured, information suchas the rated receiving bandwidth of the second network device may bedirectly configured for the first network device, so that the firstnetwork device can obtain the rated receiving bandwidth of the secondnetwork device from the configuration information.

103. The first network device sends a data flow to the second networkdevice based on the packet sending control information, and the secondnetwork device receives the data flow based on the rated receivingbandwidth.

It should be understood that the data flow sent by the first networkdevice to the second network device based on the packet sending controlinformation may be one data flow (in this case, the data flow may be anyone of all data flows sent by the first network device to the secondnetwork device), or may be a plurality of data flows (the plurality ofdata flows may be all data flows sent by the first network device to thesecond network device).

In this application, the packet sending control information isdetermined based on the active flow quantity and the rated receivingbandwidth of the second network device, and the data flow sent from thefirst network device to the second network device is controlled based onthe packet sending control information, so that the second networkdevice can achieve a full throughput state, thereby improvingtransmission efficiency of the data flow.

When the packet sending control information is determined based on theactive flow quantity and the rated receiving bandwidth of the secondnetwork device, the packet sending control information may be determinedbased on the active flow quantity by using different methods.

For example, when the active flow quantity is relatively small, thenetwork has strong tolerance for burst data. In this case, only amaximum data transmission volume of the data flow within a period needsto be controlled. However, when the active flow quantity is relativelylarge, a plurality of concurrent flows have great impact on the network.To avoid network congestion caused by a large amount of burst data, anallocation period of a network card (the network card is located at areceive end and is responsible for allocating a sending period of datapackets) can be controlled, and a single packet is sent per period (thatis, a transmission interval between data packets is strictly controlled,and transmission of each data packet can be considered as a period).

Optionally, when the active flow quantity is less than a firstthreshold, the first network device determines, based on formula (1),the packet sending control information used to send a data flow to thesecond network device.

$\begin{matrix}{V = \frac{C*T}{active\_ qp}} & (1)\end{matrix}$

In formula (1), C is the rated receiving bandwidth of the second networkdevice, active_qp is the active flow quantity, T is a time required fora data packet of the data flow sent by the first network device toarrive at the second network device, and V is a data volume of the dataflow sent by the first network device to the second network devicewithin T.

The packet sending control information is determined based on formula(1), and the packet sending control information is specifically used toinstruct the first network device to send data packets with a datavolume V in the data flow to the second network device within T. Itshould be understood that in this case, the packet sending controlinformation indicates only the data volume of the data packets in thedata flow sent within T, but a time interval between data packets is notlimited, provided that the data volume of the data packets in the dataflow within T reaches V.

After the packet sending control information is obtained based onformula (1), that the first network device sends a data flow to thesecond network device based on the packet sending control informationincludes: The first network device sends data packets with a data volumeV in the data flow to the second network device within T.

The data volume (data volume) may be a length of the data packets in thedata flow. For example, a data flow 1 includes a data packet 1, a datapacket 2, and a data packet 3, where each data packet has a length of 4bytes, and then the data flow 1 has a length of 12 bytes.

T may be preset. Specifically, T may be a time for a data packet toarrive at the receive end when the data packet is sent at a specificrate when the network is idle.

Alternatively, T may be specifically a round-trip time (round-trip time,RTT). The RTT indicates a total delay between a time when the transmitend sends data and a time when the transmit end receives anacknowledgement from the receive end (the receive end sends theacknowledgement immediately after receiving the data). The RTT may beobtained by measuring a static delay when the network device isinitialized and the network is idle.

In this application, when the active flow quantity is relatively small,the network has strong tolerance to burst data, so that only a maximumdata transmission volume of the data flow within a period needs to becontrolled, and control on sending of the data flow can be simplified.

Optionally, when the active flow quantity is less than or equal to thefirst threshold, the first network device determines, based on formula(2), the packet sending control information used to send a data flow tothe second network device.

$\begin{matrix}{{interval} = \frac{1{pkt}*{active\_ qp}}{C}} & (2)\end{matrix}$

In formula (2), 1pkt is a length of a single data packet, active_qp isthe active flow quantity, C is the rated receiving bandwidth of thesecond network device, and “interval” is a time interval betweenadjacent data packets when the first network device sends a data flow.

The packet sending control information is determined based on formula(2), and the packet sending control information specifically indicatesthat a transmission time interval between data packets when the firstnetwork device sends each data flow reaches a value indicated by“interval”.

After the packet sending control information is obtained based onformula (2), that the first network device sends a data flow to thesecond network device based on the packet sending control informationincludes: The first network device sends a data packet in the data flowto the second network device based on the time interval indicated by“interval”.

The length of the single data packet may be specifically a size of thedata volume of the single data packet, for example, if the size of thedata volume of the single data packet is 3 bytes, the length of thesingle data packet is also 3 bytes.

A derivation process of formula (2) is as follows:

Bandwidth is divided evenly among all data flows, so that a sending rateof each data flow is

$\frac{C}{active\_ qp}$

A sending rate of each data flow at the transmit end is

$\frac{1{pkt}}{interval}.$

Formula (3) can be obtained to enable the receive end to reach the fullthroughput state, and formula (2) can be obtained by transformingformula (3).

$\begin{matrix}{\frac{C}{active\_ qp} = \frac{1{pkt}}{interval}} & (3)\end{matrix}$

In this application, when the active flow quantity is relatively large,a plurality of concurrent flows cause a heavy burden to the network.Impact of the plurality of concurrent flows on the network can beavoided by properly setting the transmission time interval between datapackets, so that network congestion can be avoided.

In determining the packet sending control information based on theactive flow quantity and the rated receiving bandwidth of the secondnetwork device, in addition to determining the packet sending controlinformation for each data flow based on formula (1) or formula (2) (inthis case, the packet sending control information for each data flow isdetermined using the same method), the packet sending controlinformation for the data flow may be determined based on a specificsituation of the data flow (for example, a priority), in which casepacket sending control information obtained for different data flows maybe different. A method for determining the packet sending controlinformation for the data flow is described in detail below.

Optionally, that the first network device determines, based on theactive flow quantity and the rated receiving bandwidth of the secondnetwork device, packet sending control information used to send a dataflow to the second network device includes: The first network devicedetermines, based on the active flow quantity, the rated receivingbandwidth of the second network device, and attribute information of thedata flow, the packet sending control information used to send the dataflow to the second network device.

The attribute information of the data flow includes at least one ofapplication information of the data flow and data volume information ofthe data flow, the application information of the data flow is used toindicate a service type to which a data packet of the data flow belongs,and the data volume information of the data flow is used to indicate adata volume of data packets that belong to the data flow and that aresent by the first network device within a preset time.

The application information of the data flow may specifically indicate aservice type (for example, audio or video) to which the data packet ofthe data flow belongs, a priority corresponding to the service type, andthe like.

In this application, when the packet sending control information of thedata flow is determined, the packet sending control information can beproperly determined for the data flow based on the attribute informationof the data flow.

Optionally, when the active flow quantity is less than the firstthreshold, the first network device determines, based on formula (4),the packet sending control information used to send a data flow to thesecond network device.

$\begin{matrix}{V = \frac{C*T*w}{active\_ qp}} & (4)\end{matrix}$

In formula (4), C is the rated receiving bandwidth of the second networkdevice, active_qp is the active flow quantity, T is a time required fora data packet of the data flow sent by the first network device toarrive at the second network device, w is a weight of the data flow, wis determined based on the attribute information of the data flow, and Vis a data volume of the data flow sent by the first network device tothe second network device within T.

After the packet sending control information is obtained based onformula (4), that the first network device sends a data flow to thesecond network device based on the packet sending control informationincludes: The first network device sends data packets with a data volumeV in the data flow to the second network device within T.

It should be understood that w may be determined based on theapplication information of the data flow and/or the data volumeinformation of the data flow in the attribute information of the dataflow.

Optionally, in formula (4), the value of w is positively correlated withimportance of the service type indicated by the application informationof the data flow.

Specifically, higher importance of the service type indicated by theapplication information of the data flow in formula (4) indicates alarger value of w.

Optionally, in formula (4), the value of w is positively correlated witha priority of a service indicated by the application information of thedata flow. For example, a higher priority of the service indicated bythe application information of the data flow indicates a larger value ofw.

Optionally, in formula (4), the value of w is inversely correlated witha data volume indicated by the data volume information of the data flow.Specifically, a larger data volume indicated by the data volumeinformation of the data flow indicates a smaller value of w.

In this application, when the data transmission volume of the data flowis determined, the data transmission volume can be properly determinedfor the data flow based on the attribute information of the data flow.

Optionally, when the active flow quantity is greater than or equal tothe first threshold, the first network device determines, based onformula (5), the packet sending control information used to send a dataflow to the second network device.

$\begin{matrix}{{interval} = \frac{1{pkt}*{active\_ qp}*w}{C}} & (5)\end{matrix}$

In formula (5), 1pkt is a length of a single data packet, active_qp isthe active flow quantity, w is a weight of the data flow, w isdetermined based on the attribute information of the data flow, C is therated receiving bandwidth of the second network device, and “interval”is a time interval between adjacent data packets when the first networkdevice sends the data flow.

After the packet sending control information is obtained based onformula (5), that the first network device sends a data flow to thesecond network device based on the packet sending control informationincludes: The first network device sends a data packet in the data flowto the second network device based on the time interval indicated by“interval”.

Optionally, in formula (5), the value of w is inversely correlated withimportance of the service type indicated by the application informationof the data flow.

Specifically, in formula (5), higher importance of the service typeindicated by the application information of the data flow indicates asmaller value of w.

Optionally, in formula (5), the value of w is inversely correlated witha priority of a service indicated by the application information of thedata flow.

For example, a higher priority of the service indicated by theapplication information of the data flow indicates a smaller value of w.

Optionally, in formula (5), the value of w is positively correlated witha data volume indicated by the data volume information of the data flow.Specifically, a larger data volume indicated by the data volumeinformation of the data flow indicates a larger value of w.

In this application, when the data packet transmission time interval ofthe data flow is determined, the data packet transmission time intervalcan be properly determined for the data flow based on the attributeinformation of the data flow.

Optionally, when w is determined based on the application information ofthe data flow in the attribute information of the data flow, w=w1, and avalue of w1 is positively correlated with importance of the service typeindicated by the application information of the data flow. For example,higher importance of the service type indicated by the applicationinformation of the data flow indicates a larger value of w1. In thiscase, formula (4) can be transformed into formula (6). In this case, thepacket sending control information used to send the data flow to thesecond network device may be determined directly based on formula (6).

$\begin{matrix}{V = \frac{C*T*w\; 1}{active\_ qp}} & (6)\end{matrix}$

In formula (6), w1 is determined based on the application information ofthe data flow in the attribute information of the data flow, and otherparameters have the same meanings as those in formula (4).

Optionally, when w is determined based on the data volume information ofthe data flow, w=w2, and a value of w2 is inversely correlated with thedata volume indicated by the data volume information of the data flow.For example, a larger data volume indicated by the data volumeinformation of the data flow indicates a smaller value of w2. In thiscase, formula (4) can be transformed into formula (7). In this case, thepacket sending control information used to send the data flow to thesecond network device may be determined directly based on formula (7).

$\begin{matrix}{V = \frac{C*T*w\; 1}{active\_ qp}} & (7)\end{matrix}$

In formula (7), w2 is determined based on the data volume information ofthe data flow, and other parameters have the same meanings as those informula (4).

Optionally, when w may be determined based on the applicationinformation of the data flow and the data volume information of the dataflow in the attribute information of the data flow, w=w1×w2, a value ofw1 is positively correlated with importance of the service typeindicated by the application information of the data flow, and a valueof w2 is inversely correlated with the data volume indicated by the datavolume information of the data flow. In this case, formula (4) can betransformed into formula (8). In this case, the packet sending controlinformation used to send the data flow to the second network device maybe determined directly based on formula (8).

$\begin{matrix}{V = \frac{C*T*w\; 1*w\; 2}{active\_ qp}} & (8)\end{matrix}$

In formula (8), w1 is determined based on the application information ofthe data flow in the attribute information of the data flow, w2 isdetermined based on the data volume information of the data flow, andother parameters have the same meanings as those in formula (3).

The congestion control method according to the embodiments of thepresent application has been described in detail above from theperspective of the transmit end (the first network device) withreference to FIG. 2. The congestion control method according to theembodiments of the present application is described in detail below fromthe perspective of the receive end (the second network device) withreference to FIG. 3.

FIG. 3 is a schematic flowchart of a congestion control method accordingto an embodiment of this application. The method shown in FIG. 3 mayalso be performed by a network device to reduce congestion in networkssuch as a data center network and a metropolitan area network, and afirst network device and a second network device are devices in thesenetworks. The method shown in FIG. 3 includes step 201 to step 203.These steps are described in detail below.

201. The second network device determines an active flow quantity basedon a data flow to which data packets received from the first networkdevice belong.

202. The second network device sends a first message to the firstnetwork device, where the first message carries the active flowquantity.

The active flow quantity is used by the first network device todetermine packet sending control information used to send a data flow tothe second network device, where the packet sending control informationindicates that when the first network device sends the data flow to thesecond network device based on the packet sending control information,actual receiving bandwidth of the second network device reaches ratedreceiving bandwidth of the second network device.

203. The second network device receives, based on the rated receivingbandwidth, the data flow sent by the first network device.

It should be understood that step 101 to step 103 in the method shown inFIG. 2 correspond to step 201 to step 203 in the method shown in FIG. 3,and the relevant definitions and explanations of step 101 to step 103also apply to step 201 to step 203. To avoid repetition, details are notdescribed herein again.

In this application, the second network device reports the active flowquantity to the first network device, so that the first network devicecan determine the packet sending control information based on the activeflow quantity and the rated receiving bandwidth of the second networkdevice, and controls, based on the packet sending control information,the first network device to send the data flow to the second networkdevice, so that the second network device can receive, based on therated receiving bandwidth, the data flow sent by the first networkdevice, and the second network device can reach a full throughput state,thereby improving transmission efficiency of the data flow.

Optionally, in an embodiment, that the second network device determinesthe active flow quantity based on a data flow to which data packetsreceived from the first network device belong includes: The secondnetwork device receives the initial packet in a first group of datapackets sent by the first network device, and increases a current activeflow quantity by 1 to obtain a first active flow quantity; the secondnetwork device receives the tail packet in the first group of datapackets sent by the first network device, and determines a firstcongestion value based on a quantity of data packets carrying anexternal congestion notification ECN identifier in the first group ofdata packets; when the first congestion value is less than a congestionthreshold, the second network device decreases the first active flowquantity by 1 to obtain a second active flow quantity; and when thefirst congestion value is greater than or equal to the congestionthreshold, the second network device keeps the first active flowquantity unchanged.

Determining of the active flow quantity by the second network devicebased on a data flow to which data packets received from the firstnetwork device belong is described in detail below with reference toFIG. 4 and FIG. 5.

FIG. 4 is a flowchart of a method for counting an active flow quantityaccording to an embodiment of this application. A second network devicein FIG. 4 corresponds to the receive end 1 or the receive end 2 in FIG.1, and is configured to receive a data flow; and a first network devicein FIG. 4 corresponds to the transmit end (the transmit end 1, thetransmit end 2, or the transmit end 3) in FIG. 1, and is configured tosend a data flow. A process shown in FIG. 4 may include at least step301 to step 304; and further, the process shown in FIG. 4 may includestep 305 to step 308. These steps are described in detail below.

301. The second network device receives the initial packet in a firstgroup of data packets.

In this application, each group of data packets includes a certainquantity of data packets, and each group of data packets includes theinitial packet and the tail packet. After receiving a data packet, thesecond network device may identify whether the data packet is theinitial packet or the tail packet by identifying whether the data packetcarries an identifier of the initial packet and an identifier of thetail packet.

The identifier of the initial packet and the identifier of the tailpacket can be defined using two methods. The two methods are describedbelow.

Method 1:

When method is performed by a network device to reduce congestion in anRoCEv2 scenario, data packets may be grouped based on a message(message) as defined by the RoCEv2 protocol. Specifically, the datapackets may be grouped based on a message (Message) (the message is alogical group at an application layer). The first packet of the messageis considered as the initial packet, the last packet of the message isconsidered as the tail packet, and the initial packet and the tailpacket may be specifically defined in an opcode field of a basetransport header (Base Transport Header, BTH) of an RoCEv2 packet.

Method 2:

Data packets may be grouped based on a segment. Specifically,corresponding data packets within a period that are fed back based on aninitial rate or the active flow quantity may be grouped into a group,the first packet in the segment is referred to as the initial packet,and the last packet in the segment is referred to as the tail packet.The two fields may be defined in reserved fields (such as an rsvd7field) in the BTH, and a flag of each field may occupy 1 bit.

302. The second network device increases a current active flow quantityby 1 to obtain a first active flow quantity.

The current active flow quantity in step 302 is a quantity of activeflows counted by the second network device before receiving the initialpacket in the first group of data packets. When receiving the initialpacket in the first group of data packets, the second network deviceneeds to update the active flow quantity, that is, to increase theactive flow quantity counted before receiving the initial packet in thefirst group of data packets by 1.

303. The second network device receives the tail packet in the firstgroup of data packets.

It should be understood that the initial packet in the first group ofdata packets may be the first packet in the first group of data packetsreceived by the second network device, and the tail packet in the firstgroup of data packets may be the last packet in the first group of datapackets received by the second network device. A quantity of datapackets included in each group of data packets may be preset.

In addition, each data packet may carry an identifier in a certainfield, and a value of the identifier is used to indicate a type of thedata packet (specifically, the initial packet, the tail packet, or adata packet between the initial packet and the tail packet).

Optionally, each data packet further includes a data packet identifier,where the data packet identifier is used to indicate a type of the datapacket. Specifically, a value of the identifier may be used to indicatethat the data packet is the initial packet, the tail packet, or a datapacket between the initial packet and the tail packet in a group of datapackets.

Specifically, the data packet identifier may be carried in a packetheader or a payload (payload) of a packet, or the data packet identifiermay be carried in a field outside the packet, and the field carrying thedata packet identifier is transmitted together with the packet, so thatthe first network device can identify the type of the data packet basedon the field.

For example, in a scenario based on remote direct memory access overconverged Ethernet version 2 (remote direct memory access over convergedethernet version 2, RoCEv2), the data packet identifier may be carriedin an opcode field in an RoCEv2 packet, or the data packet identifiermay be carried in a reserved field (such as an rsvd7 field) in theRoCEv2 packet.

It should be understood that the data packets in the first group of datapackets belong to a same data flow.

304. The second network device determines a first congestion value basedon a quantity of data packets carrying an external congestionnotification ECN identifier in the first group of data packets, andupdates the active flow quantity based on a relationship between thefirst congestion value and a congestion threshold.

Optionally, in step 304, the first active flow quantity needs to beupdated again based on the quantity of data packets carrying the ECNidentifier in the first group of data packets. If the first congestionvalue is less than the congestion threshold, the active flow quantitycounted by the second network device after receiving the tail packet inthe first group of data packets is a second active flow quantity; and ifthe first congestion value is greater than or equal to the congestionthreshold, the active flow quantity counted by the second network deviceafter receiving the tail packet in the first group of data packets isthe first active flow quantity. That is, after the tail packet in thefirst group of data packets is received, the counted active flowquantity is the first active flow quantity (when the first congestionvalue is greater than or equal to the congestion threshold) or thesecond active flow quantity (when the first congestion value is lessthan the congestion threshold).

In this application, when the tail packet in a group of data packets isreceived, a congestion status may be determined based on a quantity ofdata packets carrying the ECN identifier in the group of data packets,and the active flow quantity may be corrected based on the congestionstatus, so that the active flow quantity can be more accurately counted,and a more accurate active flow quantity can be obtained.

Specifically, a conventional solution does not consider the networkcongestion status during counting of the active flow quantity. Actually,the conventional solution counts the active flow quantity based on anideal situation that the network is not congested. When the network iscongested, a quantity of data packets received by a receive end within aperiod is affected, so that the counted active flow quantity isinaccurate. In this application, data packets carrying the ECNidentifier in each group of data packets are counted, so as to estimatenetwork congestion. When the network congestion degree is relativelylow, the active flow quantity can be decreased by 1; and when thenetwork congestion degree is relatively high, the active flow quantitycan be kept unchanged, so that impact of network congestion on theactive flow quantity can be reduced, and the counted active flowquantity is more accurate.

Optionally, in an embodiment, determining a first congestion value basedon a quantity of data packets carrying an ECN identifier in the firstgroup of data packets includes: determining a ratio of the quantity ofdata packets carrying the ECN identifier in the first group of datapackets to a quantity of data packets in the first group of data packetsas the first congestion value.

Specifically, a ratio of a total quantity of data packets carrying theECN identifier in the first group of data packets to the quantity ofdata packets in the first group of data packets may be determined as thefirst congestion value.

For example, the first group of data packets includes a total of 10 datapackets (including the initial packet and the tail packet), where atotal of five data packets carry the ECN identifier, and it may bedetermined, through calculation, that the first congestion value is 0.5.

In addition, the ratio of the total quantity of data packets carryingthe ECN identifier in the first group of data packets to the totalquantity of data packets in the first group of data packets mayalternatively be obtained first, and then a product of the ratio and acorrection coefficient is used as the first congestion value. Thecorrection coefficient may be a coefficient set based on an operationstatus of the network.

For example, the first group of data packets includes a total of 10 datapackets (including the initial packet and the tail packet), where eightdata packets carry the ECN identifier. Then, it can be determined,through calculation, that the ratio of the total quantity of datapackets carrying the ECN identifier to the total quantity of datapackets is 0.8. Assuming that the correction coefficient is 0.8, theproduct of the ratio and the correction coefficient, that is, 0.64, isthe first congestion value.

Optionally, before step 302, the process shown in FIG. 4 furtherincludes: determining that a data flow including the first group of datapackets is a first data flow, where the first data flow is a data flowin which a quantity of data packets received by the second networkdevice within a preset time is greater than a preset quantity.

The first data flow may be considered as a large data flow. In thisapplication, the active flow quantity is counted only for the first dataflow (for a large data flow, the active flow quantity can be properlycounted using the solution in this application), so that the solutionfor counting the active flow quantity in this application is moretargeted.

Specifically, because a small data flow includes a small quantity ofdata packets, network congestion has little impact on the small dataflow; because a large data flow includes a large quantity of datapackets, network congestion has great impact on the large data flow.Therefore, for a small data flow, the active flow quantity does not needto be counted (that is, a small data flow is not considered as an activeflow even if data packets can be received); and for a large data flow,the active flow quantity can be counted using the solution of thisapplication.

Step 301 to step 304 only show the case of counting the active flowquantity based on a group of data packets. Actually, the method forcounting the active flow quantity according to the embodiment of thisapplication can also be used to count the active flow quantity based ona plurality of groups of data packets.

Optionally, in the process shown in FIG. 4, after receiving the firstgroup of data packets and updating the active flow quantity through step301 to step 304, the second network device may further receive a secondgroup of data packets and update the active flow quantity again based onthe received second group of data packets.

305. The second network device receives the initial packet in the secondgroup of data packets.

It should be understood that the second group of data packets and thefirst group of data packets belong to a same data flow, and the secondgroup of data packets may be a group of data packets received by thesecond network device after receiving the first group of data packets;and specifically, the second group of data packets and the first groupof data packets may be two consecutive groups of data packets in thedata flow (that is, the second group of data packets is the next groupof data packets received by the second network device immediately afterreceiving the first group of data packets).

306. The second network device increases the current active flowquantity by 1 to obtain a fourth active flow quantity.

307. The second network device receives the tail packet in the secondgroup of data packets.

A specific process of step 305 to step 307 is similar to the specificprocess of step 301 to step 303. Details are not described herein again.

308. The second network device determines a second congestion valuebased on a quantity of data packets carrying the external congestionnotification ECN identifier in the second group of data packets, andupdates the active flow quantity based on a relationship between thesecond congestion value and the congestion threshold.

After the initial packet in the second group of data packets isreceived, the initial packet in the second group of data packets may beprocessed in a manner similar to that of the initial packet in the firstgroup of data packets; and after the tail packet in the second group ofdata packets is received, the second congestion value is determinedbased on both the quantity of data packets carrying the ECN identifierin the second group of data packets and the first congestion value, sothat the second congestion value does not change too much, and a slowlychanging congestion value is obtained.

Optionally, after the second network device receives the tail packet inthe second group of data packets sent by the first network device, thesecond congestion value may alternatively be determined based on boththe quantity of data packets carrying the ECN identifier in the firstgroup of data packets and the quantity of data packets carrying the ECNidentifier in the second group of data packets.

Optionally, a ratio of a total quantity of data packets carrying the ECNidentifier in both the first group of data packets and the second groupof data packets to a total quantity of data packets included in both thefirst group of data packets and the second group of data packets isdetermined as the second congestion value.

For example, the first group of data packets and the second group ofdata packets each include 10 data packets, where four data packets inthe first group of data packets carry the ECN identifier and six datapackets in the second group of data packets carry the ECN identifier.Then, the total quantity of data packets carrying the ECN identifier inthe first group of data packets and the second group of data packets is10, and the total quantity of data packets in the first group of datapackets and the second group of data packets is 20; then, the secondcongestion value is 10/20=0.5.

It should be understood that the second congestion value may bealternatively obtained as follows: obtaining a congestion value based onthe quantity of data packets carrying the ECN identifier in the firstgroup of data packets, obtaining another congestion value based on thequantity of data packets carrying the ECN identifier in the second groupof data packets, and then performing weighted summation on the twocongestion values.

Optionally, in an embodiment, determining the second congestion value ofthe network based on the quantity of data packets carrying the ECNidentifier in the second group of data packets and the first congestionvalue includes: determining a third congestion value of the networkbased on the quantity of data packets carrying the ECN identifier in thesecond group of data packets; and determining the second congestionvalue based on formula (9).

con2=x1*con3+x2*con1  (9)

In formula (9), con3 is the third congestion value, con1 is the firstcongestion value, con2 is the second congestion value, x1 is a presetfirst weight, and x2 is a preset second weight.

It should be understood that, in this application, each time the secondnetwork device receives the initial packet in a group of data packets(for example, the first group of data packets or the second group ofdata packets), the current active flow quantity needs to be increased by1; each time the second network device receives the tail packet in agroup of data packets, the active flow quantity needs to be adjustedbased on the quantity of data packets carrying the ECN identifier in thegroup of data packets (the active flow quantity is decreased by 1 orkept unchanged), so that the active flow quantity is updated in realtime.

For a better understanding of the technical solutions in thisapplication, the method for counting the active data flow quantityaccording to the embodiments of this application is described below fromthe perspective of the second network device.

FIG. 5 is a flowchart of a method for counting an active flow quantityaccording to an embodiment of this application. A process shown in FIG.5 may include at least step 401 to step 406; and further, the processshown in FIG. 5 may include step 407 to step 411. These steps aredescribed in detail below.

401. Start.

Step 401 indicates that counting of the active flow quantity is started.Step 401 may occur after one group of data packets is received and theactive flow quantity is updated and before another group of data packetsare received.

402. The second network device receives the initial packet in a firstgroup of data packets sent by the first network device, and executescounter++.

A counter is the current active flow quantity counted by the secondnetwork device. Specifically, the counter is a quantity of currentlyactive data flows counted by the second network device when the secondnetwork device receives the initial packet in the first group of datapackets sent by the first network device.

A counter obtained after counter++ is executed in step 402 is the activeflow quantity after the initial packet in the first group of datapackets is received and the current active flow quantity is updated. Thecounter obtained after counter++ is executed corresponds to the firstactive flow quantity obtained in step 102.

403. The second network device receives the tail packet in the firstgroup of data packets, and determines a first congestion value based ona quantity of data packets carrying an external congestion notificationECN identifier in the first group of data packets.

404. Determine whether the first congestion value is greater than acongestion threshold.

When the first congestion value is less than or equal to the congestionthreshold, it indicates that a congestion degree of a network isrelatively low. In this case, the current active flow quantity needs tobe decreased by 1, that is, step 405 is performed. When the firstcongestion value is greater than or equal to the congestion threshold,it indicates that network congestion is serious. In this case, thecurrent active flow quantity needs to be kept unchanged, that is, step406 is performed.

405. Execute counter—.

In step 405, a counter obtained by executing counter—corresponds to theforegoing second active flow quantity.

406. Keep the counter unchanged.

In step 406, the counter corresponds to the foregoing first active flowquantity.

407. The second network device receives the initial packet in a secondgroup of data packets sent by the first network device, and executescounter++.

A counter obtained after counter++ is executed in step 407 correspondsto the foregoing fourth active flow quantity.

408. The second network device receives the tail packet in the secondgroup of data packets, and determines a second congestion value based onthe quantity of data packets carrying the ECN identifier in the firstgroup of data packets and a quantity of data packets carrying the ECNidentifier in the second group of data packets.

409. Determine whether the second congestion value is greater than thecongestion threshold.

When the second congestion value is less than or equal to the congestionthreshold, it indicates that the congestion degree of the network isrelatively low. In this case, the current active flow quantity needs tobe decreased by 1, that is, step 410 is performed. When the secondcongestion value is greater than or equal to the congestion threshold,it indicates that the network congestion is serious. In this case, thecurrent active flow quantity needs to be kept unchanged, that is, step411 is performed.

410. Execute counter—.

In step 410, a counter obtained by executing counter—corresponds to theforegoing fifth active flow quantity.

411. Keep the counter unchanged.

In step 411, the counter corresponds to the foregoing fourth active flowquantity.

It should be understood that, in step 401 to step 411 of the processshown in FIG. 5, the counter indicates the current active flow quantity,and an addition operation or a subtraction operation needs to beperformed on the counter through different operation steps, or thecounter is kept unchanged, so as to count the current active flowquantity in real time.

The congestion control methods according to the embodiments of thisapplication have been described in detail above with reference to FIG. 1to FIG. 5. Network devices according to the embodiments of thisapplication are described in detail below with reference to FIG. 6 toFIG. 8. It should be understood that the network devices shown in FIG. 6to FIG. 8 can perform the congestion control methods according to theembodiments of this application (a network device 500 shown in FIG. 6corresponds to the foregoing first network device, and the networkdevice 500 can perform the steps performed by the foregoing firstnetwork device; and a network device 600 shown in FIG. 7 corresponds tothe foregoing second network device, and the network device 600 canperform the steps performed by the foregoing second network device). Forbrevity, repeated descriptions are appropriately omitted when thenetwork devices shown in FIG. 6 to FIG. 8 are described.

FIG. 6 is a schematic block diagram of a network device according to anembodiment of this application. The network device 500 in FIG. 6includes:

a receiving module 501, configured to receive a first message sent by asecond network device, where the first message carries an active flowquantity, and the active flow quantity is determined by the secondnetwork device based on a data flow to which data packets received froma first network device belong;

a processing module 502, configured to determine, based on the activeflow quantity and rated receiving bandwidth of the second networkdevice, packet sending control information used to send a data flow tothe second network device, where the packet sending control informationindicates that when the first network device sends the data flow to thesecond network device based on the packet sending control information,an actual receiving bandwidth of the second network device reaches therated receiving bandwidth; and

a sending module 503, configured to send the data flow to the secondnetwork device based on the packet sending control information.

Optionally, in an embodiment, the processing module 502 is configuredto: when the active flow quantity is less than a first threshold,determine, based on the following formula, the packet sending controlinformation used to send a data flow to the second network device:

$V = \frac{C*T}{active\_ qp}$

where C is the rated receiving bandwidth of the second network device,active_qp is the active flow quantity, T is a time required for a datapacket of the data flow sent by the first network device to arrive atthe second network device, and V is a data volume of the data flow sentby the first network device to the second network device within T.

The sending module 503 is configured to send data packets with a datavolume V in the data flow to the second network device within T.

Optionally, in an embodiment, the processing module 502 is configuredto: when the active flow quantity is greater than or equal to the firstthreshold, determine, based on the following formula, the packet sendingcontrol information used to send a data flow to the second networkdevice:

${interval} = \frac{1{pkt}*{active\_ qp}}{C}$

where 1pkt is a length of a single data packet, active_qp is the activeflow quantity, C is the rated receiving bandwidth of the second networkdevice, and “interval” is a time interval between adjacent data packetswhen the first network device sends the data flow.

The sending module 503 is configured to send the data packet in the dataflow to the second network device based on the time interval indicatedby “interval”.

Optionally, in an embodiment, the processing module 502 is configured todetermine, based on the active flow quantity, the rated receivingbandwidth of the second network device, and attribute information of thedata flow, the packet sending control information used to send the dataflow to the second network device, where the attribute information ofthe data flow includes at least one of application information of thedata flow and data volume information of the data flow, the applicationinformation of the data flow is used to indicate a service type to whichthe data packet of the data flow belongs, and the data volumeinformation of the data flow is used to indicate a data volume of datapackets that belong to the data flow and that are sent by the firstnetwork device within a preset time.

Optionally, in an embodiment, the processing module 502 is configuredto: when the active flow quantity is less than a first threshold,determine, based on the following formula, the packet sending controlinformation used to send a data flow to the second network device:

$V = \frac{C*T*w}{active\_ qp}$

where C is the rated receiving bandwidth of the second network device,active_qp is the active flow quantity, T is a time required for a datapacket of the data flow sent by the first network device to arrive atthe second network device, w is a weight of the data flow, w isdetermined based on the attribute information of the data flow, and V isa data volume of the data flow sent by the first network device to thesecond network device within T.

The sending module 503 is configured to send data packets with a datavolume V in the data flow to the second network device within T.

Optionally, in an embodiment, the processing module 502 is configuredto: when the active flow quantity is greater than or equal to the firstthreshold, determine, based on the following formula, the packet sendingcontrol information used to send a data flow to the second networkdevice:

${interval} = \frac{1{pkt}*{active\_ qp}*w}{C}$

where 1pkt is a length of a single data packet, active_qp is the activeflow quantity, w is a weight of the data flow, w is determined based onthe attribute information of the data flow, C is the rated receivingbandwidth of the second network device, and “interval” is a timeinterval between adjacent data packets when the first network devicesends the data flow.

The sending module 503 is configured to send the data packet in the dataflow to the second network device based on the time interval indicatedby “interval”.

FIG. 7 is a schematic block diagram of a network device according to anembodiment of this application. The network device 600 in FIG. 7includes:

a processing module 601, configured to determine an active flow quantitybased on a data flow to which data packets received from a first networkdevice belong;

a sending module 602, configured to send a first message to the firstnetwork device, where the first message carries the active flowquantity, the active flow quantity is used by the first network deviceto determine packet sending control information used to send a data flowto the second network device, the packet sending control informationindicates that when the first network device sends the data flow to thesecond network device based on the packet sending control information,actual receiving bandwidth of the second network device reaches ratedreceiving bandwidth of the second network device; and

a receiving module 603, configured to receive, based on the ratedreceiving bandwidth, the data flow sent by the first network device.

Optionally, in an embodiment, the receiving module 603 is configured toreceive the initial packet in a first group of data packets sent by thefirst network device; the processing module 601 is configured toincrease a current active flow quantity by 1 to obtain a first activeflow quantity; the receiving module 603 is configured to receive thetail packet in the first group of data packets sent by the first networkdevice; the processing module 601 is configured to: determine a firstcongestion value based on a quantity of data packets carrying anexternal congestion notification ECN identifier in the first group ofdata packets; when the first congestion value is less than a congestionthreshold, the second network device decreases the first active flowquantity by 1 to obtain a second active flow quantity; and when thefirst congestion value is greater than or equal to the congestionthreshold, the second network device keeps the first active flowquantity unchanged.

Optionally, in an embodiment, the processing module 601 is configured todetermine a ratio of the quantity of data packets carrying the ECNidentifier in the first group of data packets to a quantity of datapackets in the first group of data packets as the first congestionvalue.

Optionally, in an embodiment, after the receiving module 603 receivesthe tail packet in the first group of data packets sent by the firstnetwork device, the receiving module 603 is further configured toreceive the initial packet in a second group of data packets sent by thefirst network device. The processing module 601 is configured to:increase a third active flow quantity by 1 to obtain a fourth activeflow quantity, where the second group of data packets and the firstgroup of data packets belong to a same data flow; when the firstcongestion value is less than a congestion threshold, the third activeflow quantity is equal to the second active flow quantity; and when thefirst congestion value is greater than or equal to the congestionthreshold, the third active flow quantity is equal to the first activeflow quantity.

The receiving module 603 is configured to receive the tail packet in thesecond group of data packets sent by the first network device. Theprocessing module 601 is further configured to: determine a secondcongestion value of the network based on a quantity of data packetscarrying the ECN identifier in the second group of data packets and thefirst congestion value; when the second congestion value is less thanthe congestion threshold, the second network device decreases the fourthactive flow quantity by 1 to obtain a fifth active flow quantity; andwhen the second congestion value is greater than or equal to thecongestion threshold, the second network device keeps the fourth activeflow quantity unchanged.

Optionally, in an embodiment, the processing module 601 is configuredto: determine a third congestion value of the network based on thequantity of data packets carrying the ECN identifier in the second groupof data packets; and determine the second congestion value based on theformula con2=x1*con3+x2*con1, where con3 is the third congestion value,con1 is the first congestion value, con2 is the second congestion value,x1 is a preset first weight, and x2 is a preset second weight.

FIG. 8 is a schematic block diagram of a network device according to anembodiment of this application.

A network device 700 in FIG. 8 includes a memory 701, a transceiver 702,and a processor 703. The processor 703 may be a central processing unit(central processing unit, CPU), a general-purpose processor, a digitalsignal processor (digital signal processing, DSP), anapplication-specific integrated circuit (application-specific integratedcircuit, ASIC), a field programmable gate array (field programmable gatearray, FPGA), or another programmable logical device, a transistorlogical device, a hardware component, or any combination thereof. Thememory 701 is configured to store a program, and the processor 703 mayexecute the program stored in the memory 701. When the program stored inthe memory 701 is executed by the processor 703, the processor 703 isconfigured to perform the congestion control method according to theembodiments of this application. Specifically, the transceiver 702 andthe processor 703 may be configured to perform the foregoing stepsperformed by the first network device or the second network device.

A person of ordinary skill in the art may be aware that, in combinationwith the examples described in the embodiments disclosed in thisspecification, units and algorithm steps may be implemented byelectronic hardware or a combination of computer software and electronichardware. Whether the functions are performed by hardware or softwaredepends on particular applications and design constraint conditions ofthe technical solutions. A person skilled in the art may use differentmethods to implement the described functions for each particularapplication, but it should not be considered that the implementationgoes beyond the scope of this application.

It may be clearly understood by a person skilled in the art that, forthe purpose of convenient and brief description, for a detailed workingprocess of the foregoing system, apparatus, and unit, refer to acorresponding process in the foregoing method embodiments, and detailsare not described herein again.

In the several embodiments provided in this application, it should beunderstood that the disclosed system, apparatus, and method may beimplemented in other manners. For example, the described apparatusembodiment is merely an example. For example, the unit division ismerely logical function division and may be other division in actualimplementation. For example, a plurality of units or components may becombined or integrated into another system, or some features may beignored or not performed. In addition, the displayed or discussed mutualcouplings or direct couplings or communication connections may beimplemented by using some interfaces. The indirect couplings orcommunication connections between the apparatuses or units may beimplemented in electronic, mechanical, or other forms.

The units described as separate parts may or may not be physicallyseparate, and parts displayed as units may or may not be physical units,may be located in one position, or may be distributed on a plurality ofnetwork units. Some or all of the units may be selected based on actualrequirements to achieve the objectives of the solutions of theembodiments.

In addition, functional units in the embodiments of this application maybe integrated into one processing unit, or each of the units may existalone physically, or two or more units are integrated into one unit.

When the functions are implemented in the form of a software functionalunit and sold or used as an independent product, the functions may bestored in a computer-readable storage medium. Based on such anunderstanding, the technical solutions of this application essentially,or some of the technical solutions may be implemented in a form of asoftware product. The software product is stored in a storage medium,and includes several instructions for instructing a computer device(which may be a personal computer, a server, or a network device) toperform all or some of the steps of the methods described in theembodiments of this application. The foregoing storage medium includes:any medium that can store program code, such as a USB flash drive, aremovable hard disk, a read-only memory (read-only memory, ROM), arandom access memory (random access memory, RAM), a magnetic disk, or anoptical disc.

The foregoing descriptions are merely specific implementations of thisapplication, but are not intended to limit the protection scope of thisapplication. Any variation or replacement readily figured out by aperson skilled in the art within the technical scope disclosed in thisapplication shall fall within the protection scope of this application.Therefore, the protection scope of this application shall be subject tothe protection scope of the claims.

What is claimed is:
 1. A congestion control method, wherein the methodis performed by a first network device to reduce congestion in a datacenter network, comprising: sending a data flow to a second networkdevice; receiving a first message from the second network device thatcarries an active flow quantity that is based on the data flowtransmitted by the first network device to the second network device;determining, based on the active flow quantity and rated receivingbandwidth of the second network device, packet sending controlinformation used to send the data flow to the second network device thatindicates: when the first network device sends the data flow to thesecond network device based on the packet sending control information,actual receiving bandwidth of the second network device reaches therated receiving bandwidth; and sending, based on the packet sendingcontrol information, a second data flow to the second network device tocorrespond to the actual receiving bandwidth.
 2. The method according toclaim 1, wherein the determining, by the first network device based onthe active flow quantity and rated receiving bandwidth of the secondnetwork device, packet sending control information used to send the dataflow to the second network device comprises: when the active flowquantity is less than a first threshold, determining, by the firstnetwork device based on the following formula, the packet sendingcontrol information used to send the data flow to the second networkdevice: $V = \frac{C*T}{active\_ qp}$ wherein C is the rated receivingbandwidth of the second network device, active_qp is the active flowquantity, T is a time required for a data packet sent by the firstnetwork device to the second network device to arrive at the secondnetwork device when the network is idle, and V is a data volume of thedata flow sent by the first network device to the second network devicewithin T; and the sending, by the first network device based on thepacket sending control information, the data flow to the second networkdevice comprises: sending, by the first network device, data packetswith a data volume V in the data flow to the second network devicewithin T.
 3. The method according to claim 1, wherein the determining,by the first network device based on the active flow quantity and ratedreceiving bandwidth of the second network device, packet sending controlinformation used to send the data flow to the second network devicecomprises: when the active flow quantity is greater than or equal to thefirst threshold, determining, by the first network device based on thefollowing formula, the packet sending control information used to sendthe data flow to the second network device:${interval} = \frac{1{pkt}*{active\_ qp}}{C}$ wherein 1pkt is a lengthof a single data packet, active_qp is the active flow quantity, C is therated receiving bandwidth of the second network device, and “interval”is a time interval between adjacent data packets when the first networkdevice sends the data flow; and the sending, by the first network devicebased on the packet sending control information, the data flow to thesecond network device comprises: sending, by the first network devicebased on the time interval indicated by “interval”, the data packet inthe data flow to the second network device.
 4. The method according toclaim 1, wherein the determining, by the first network device based onthe active flow quantity and rated receiving bandwidth of the secondnetwork device, packet sending control information used to send the dataflow to the second network device comprises: determining, by the firstnetwork device based on the active flow quantity, the rated receivingbandwidth of the second network device, and attribute information of thedata flow, the packet sending control information used to send the dataflow to the second network device, wherein the attribute information ofthe data flow comprises at least one of application information of thedata flow or data volume information of the data flow, the applicationinformation of the data flow is used to indicate a service type to whicha data packet of the data flow belongs, and the data volume informationof the data flow is used to indicate a data volume of data packets thatbelong to a first data flow and that are sent by the first networkdevice within a preset time.
 5. The method according to claim 4, whereinthe determining, by the first network device based on the active flowquantity, the rated receiving bandwidth of the second network device,and attribute information of the data flow, the packet sending controlinformation used to send the data flow to the second network devicecomprises: when the active flow quantity is less than a first threshold,determining, by the first network device based on the following formula,the packet sending control information used to send the data flow to thesecond network device: $V = \frac{C*T*w}{active\_ qp}$ wherein C is therated receiving bandwidth of the second network device, active_qp is theactive flow quantity, T is a time required for a data packet sent by thefirst network device to the second network device to arrive at thesecond network device when the network is idle, w is a weight of thedata flow, w is determined based on the attribute information of thedata flow, and V is a data volume of the data flow sent by the firstnetwork device to the second network device within T; and the sending,by the first network device based on the packet sending controlinformation, the data flow to the second network device comprises:sending, by the first network device, data packets with a data volume Vin the data flow to the second network device within T.
 6. The methodaccording to claim 4, wherein the determining, by the first networkdevice based on the active flow quantity, the rated receiving bandwidthof the second network device, and attribute information of the dataflow, the packet sending control information used to send the data flowto the second network device comprises: when the active flow quantity isgreater than or equal to the first threshold, determining, by the firstnetwork device based on the following formula, the packet sendingcontrol information used to send the data flow to the second networkdevice: ${interval} = \frac{1{pkt}*{active\_ qp}*w}{C}$ wherein 1pkt isa length of a single data packet, active_qp is the active flow quantity,w is the weight of the data flow, w is determined based on the attributeinformation of the data flow, C is the rated receiving bandwidth of thesecond network device, and “interval” is a time interval betweenadjacent data packets when the first network device sends the data flow;and the sending, by the first network device based on the packet sendingcontrol information, the data flow to the second network devicecomprises: sending, by the first network device based on the timeinterval indicated by “interval”, the data packet in the data flow tothe second network device.
 7. A congestion control method, wherein themethod is performed by a second network device to reduce congestion in adata center network, the data center network comprises a first networkdevice and a second network device, the method comprising: receiving adata flow sent by a first network device; determining an active flowquantity based on the data flow received from the first network devicebelong; sending a first message to the first network device that carriesthe active flow quantity; and receiving a second data flow sent by thefirst network device.
 8. The method according to claim 7, wherein thedetermining, by the second network device, an active flow quantity basedon a data flow to which data packets received from the first networkdevice belong comprises: receiving, by the second network device, theinitial packet in a first group of data packets sent by the firstnetwork device, and increasing a current active flow quantity by 1 toobtain a first active flow quantity; receiving, by the second networkdevice, the tail packet in the first group of data packets sent by thefirst network device, and determining a first congestion value based ona quantity of data packets carrying an external congestion notificationECN identifier in the first group of data packets; and when the firstcongestion value is less than a congestion threshold, decreasing, by thesecond network device, the first active flow quantity by 1 to obtain asecond active flow quantity; or when the first congestion value isgreater than or equal to a congestion threshold, keeping, by the secondnetwork device, the first active flow quantity unchanged.
 9. The methodaccording to claim 8, wherein the determining a first congestion valuebased on a quantity of data packets carrying an ECN identifier in thefirst group of data packets comprises: determining a ratio of thequantity of data packets carrying the ECN identifier in the first groupof data packets to a quantity of data packets in the first group of datapackets as the first congestion value.
 10. The method according to claim8, wherein after the receiving, by the second network device, the tailpacket in the first group of data packets sent by the first networkdevice, the method further comprises: receiving, by the second networkdevice, the initial packet in a second group of data packets sent by thefirst network device, and increasing a third active flow quantity by 1to obtain a fourth active flow quantity, wherein the second group ofdata packets and the first group of data packets belong to a same dataflow, the third active flow quantity is equal to the second active flowquantity when the first congestion value is less than the congestionthreshold, and the third active flow quantity is equal to the firstactive flow quantity when the first congestion value is greater than orequal to the congestion threshold; receiving, by the second networkdevice, the tail packet in the second group of data packets sent by thefirst network device, and determining a second congestion value of thenetwork based on a quantity of data packets carrying the ECN identifierin the second group of data packets and the first congestion value; andwhen the second congestion value is less than the congestion threshold,decreasing, by the second network device, the fourth active flowquantity by 1 to obtain a fifth active flow quantity; or when the secondcongestion value is greater than or equal to the congestion threshold,keeping, by the second network device, the fourth active flow quantityunchanged.
 11. The method according to claim 10, wherein the determininga second congestion value of the network based on a quantity of datapackets carrying the ECN identifier in the second group of data packetsand the first congestion value comprises: determining a third congestionvalue of the network based on the quantity of data packets carrying theECN identifier in the second group of data packets; and determining thesecond congestion value based on a formula con2=x1*con3+x2*con1, whereincon3 is the third congestion value, con1 is the first congestion value,con2 is the second congestion value, x1 is a preset first weight, and x2is a preset second weight.
 12. A first network device, wherein the firstnetwork device comprises: a non-transitory memory storing instructions;and a processor coupled to the non-transitory memory; wherein theinstructions, when executed by the processor, cause the first networkdevice to be configured to: receive a first message sent by a secondnetwork device, wherein the first message carries an active flowquantity, and the active flow quantity is a quantity determined by thesecond network device based on a data flow to which data packetsreceived from the first network device belong; determine, based on theactive flow quantity and rated receiving bandwidth of the second networkdevice, packet sending control information used to send the data flow tothe second network device, wherein the packet sending controlinformation indicates that: when the first network device sends the dataflow to the second network device based on the packet sending controlinformation, actual receiving bandwidth of the second network devicereaches the rated receiving bandwidth; and send the data flow to thesecond network device based on the packet sending control information.13. The first network device according to claim 12, wherein theinstructions, when executed by the processor, further cause the firstnetwork device to be configured to: when the active flow quantity isless than a first threshold, determine based on the following formula,the packet sending control information used to send the data flow to thesecond network device: $V = \frac{C*T}{active\_ qp}$ wherein C is therated receiving bandwidth of the second network device, active_qp is theactive flow quantity, T is a time required for a data packet sent by thefirst network device to the second network device to arrive at thesecond network device when the network is idle, and V is a data volumeof the data flow sent by the first network device to the second networkdevice within T; and send data packets with a data volume V in the dataflow to the second network device within T.
 14. The first network deviceaccording to claim 12, wherein the instructions, when executed by theprocessor, further cause the first network device to be configured to:when the active flow quantity is greater than or equal to the firstthreshold, determine based on the following formula, the packet sendingcontrol information used to send the data flow to the second networkdevice: ${interval} = \frac{1{pkt}*{active\_ qp}}{C}$ wherein 1pkt is alength of a single data packet, active_qp is the active flow quantity, Cis the rated receiving bandwidth of the second network device, and“interval” is a time interval between adjacent data packets when thefirst network device sends the data flow; and send the data packet inthe data flow to the second network device based on the time intervalindicated by “interval”.
 15. The first network device according to claim12, wherein the instructions, when executed by the processor, furthercause the first network device to be configured to: determine based onthe active flow quantity, the rated receiving bandwidth of the secondnetwork device, and attribute information of the data flow, the packetsending control information used to send the data flow to the secondnetwork device, wherein the attribute information of the data flowcomprises at least one of application information of the data flow anddata volume information of the data flow, the application information ofthe data flow is used to indicate a service type to which a data packetof the data flow belongs, and the data volume information of the dataflow is used to indicate a data volume of data packets that belong to afirst data flow and that are sent by the first network device within apreset time.
 16. The first network device according to claim 15, whereinthe instructions, when executed by the processor, further cause thefirst network device to be configured to: when the active flow quantityis less than a first threshold, determine based on the followingformula, the packet sending control information used to send the dataflow to the second network device: $V = \frac{C*T*w}{active\_ qp}$wherein C is the rated receiving bandwidth of the second network device,active_qp is the active flow quantity, T is a time required for a datapacket sent by the first network device to the second network device toarrive at the second network device when the network is idle, w is aweight of the data flow, w is determined based on the attributeinformation of the data flow, and V is a data volume of the data flowsent by the first network device to the second network device within T;and send data packets with a data volume V in the data flow to thesecond network device within T.
 17. The first network device accordingto claim 15, wherein the instructions, when executed by the processor,further cause the first network device to be configured to: when theactive flow quantity is greater than or equal to the first threshold,determine based on the following formula, the packet sending controlinformation used to send the data flow to the second network device:${interval} = \frac{1{pkt}*{active\_ qp}*w}{C}$ wherein 1pkt is alength of a single data packet, active_qp is the active flow quantity, wis the weight of the data flow, w is determined based on the attributeinformation of the data flow, C is the rated receiving bandwidth of thesecond network device, and “interval” is a time interval betweenadjacent data packets when the first network device sends the data flow;and send the data packet in the data flow to the second network devicebased on the time interval indicated by “interval”.
 18. A second networkdevice, comprising: a non-transitory memory storing instructions; and aprocessor coupled to the non-transitory memory; wherein theinstructions, when executed by the processor, cause the second networkdevice to be configured to: determine an active flow quantity based on adata flow to which data packets received from a first network devicebelong; send a first message to the first network device, wherein thefirst message carries the active flow quantity, the active flow quantityis used by the first network device to determine packet sending controlinformation used to send the data flow to the second network device, andthe packet sending control information indicates that: when the firstnetwork device sends the data flow to the second network device based onthe packet sending control information, actual receiving bandwidth ofthe second network device reaches rated receiving bandwidth of thesecond network device; and receive based on the rated receivingbandwidth, a second data flow sent by the first network device.
 19. Thesecond network device according to claim 18, wherein the instructions,when executed by the processor, further cause the second network deviceto be configured to: receive the initial packet in a first group of datapackets sent by the first network device; increase a current active flowquantity by 1 to obtain a first active flow quantity; receive the tailpacket in the first group of data packets sent by the first networkdevice; and determine a first congestion value based on a quantity ofdata packets carrying an external congestion notification ECN identifierin the first group of data packets; and when the first congestion valueis less than a congestion threshold, decrease the first active flowquantity by 1 to obtain a second active flow quantity; or when the firstcongestion value is greater than or equal to a congestion threshold,keep, by the second network device, the first active flow quantityunchanged.
 20. The second network device according to claim 19, whereinthe instructions, when executed by the processor, further cause thesecond network device to be configured to: determine a ratio of thequantity of data packets carrying the ECN identifier in the first groupof data packets to a quantity of data packets in the first group of datapackets as the first congestion value.
 21. The second network deviceaccording to claim 19, wherein after the second network device receivesthe tail packet in the first group of data packets sent by the firstnetwork device, the instructions, when executed by the processor,further cause the second network device to be configured to: receive theinitial packet in a second group of data packets sent by the firstnetwork device; increase a third active flow quantity by 1 to obtain afourth active flow quantity, wherein the second group of data packetsand the first group of data packets belong to a same data flow, thethird active flow quantity is equal to the second active flow quantitywhen the first congestion value is less than the congestion threshold,and the third active flow quantity is equal to the first active flowquantity when the first congestion value is greater than or equal to thecongestion threshold; receive the tail packet in the second group ofdata packets sent by the first network device; and determine a secondcongestion value of the network based on a quantity of data packetscarrying the ECN identifier in the second group of data packets and thefirst congestion value; and when the second congestion value is lessthan the congestion threshold, decrease the fourth active flow quantityby 1 to obtain a fifth active flow quantity; or when the secondcongestion value is greater than or equal to the congestion threshold,keep, by the second network device, the fourth active flow quantityunchanged.
 22. The second network device according to claim 21, whereinthe instructions, when executed by the processor, further cause thesecond network device to be configured to: determine a third congestionvalue of the network based on the quantity of data packets carrying theECN identifier in the second group of data packets; and determine thesecond congestion value based on a formula con2=x1*con3+x2*con1, whereincon3 is the third congestion value, con1 is the first congestion value,con2 is the second congestion value, x1 is a preset first weight, and x2is a preset second weight.